package com;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {
	private String account;
	private LoginUser loginUser;
	
	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public LoginUser getLoginUser() {
		return loginUser;
	}

	public void setLoginUser(LoginUser loginUser) {
		this.loginUser = loginUser;
	}

	public String execute(){
		System.out.println("account="+loginUser.getAccount());
		System.out.println("LoginAction: execute() is called!");
		return "success";
	}
	
	public void validate() {
    	System.out.println("LoginAction: validate() is called!");
    	String account = loginUser.getAccount();
    	String password = loginUser.getPassword();
        if (account == null || account.equals("")) {
        	System.out.println("xx");
        	this.addFieldError("account","请输入您的用户名！");
       	}
        if (password == null || password.equals("")) {
       	this.addFieldError("password", "请输入您的密码！");}
  }
}
